package com.bestvike.stone.core.threading.holder;

import com.bestvike.stone.core.threading.ThreadUtils;

/**
 * 创建任务或子线程时调用,存储当前线程本地变量
 * Created by 许崇雷 on 2018-02-06.
 */
public final class CopyThreadLocalsHolder {
    private final Thread thread;
    private final Object inheritableThreadLocals;

    public CopyThreadLocalsHolder() {
        this.thread = Thread.currentThread();
        this.inheritableThreadLocals = ThreadUtils.copyInheritableThreadLocals(this.thread);
    }

    public Thread getThread() {
        return this.thread;
    }

    public Object getInheritableThreadLocals() {
        return this.inheritableThreadLocals;
    }
}
